
/**
 * AppleIIGo
 * Graphics Tablet Interface Card class
 * (C) 2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include "GraphicsTabletInterfaceCard.h"

GraphicsTabletInterfaceCard::GraphicsTabletInterfaceCard(
	Motherboard * motherboard, char * slotDeviceName) :
SlotDevice(motherboard, slotDeviceName) {
}

void GraphicsTabletInterfaceCard::onMemoryRequested() {
	romMemoryOffset = motherboard->getMemory()->requestMemory(
		GRAPHICSTABLETINTERFACECARD_ROM_BYTENUM);
}

void GraphicsTabletInterfaceCard::onMemoryAllocated() {
	romMemory = motherboard->getMemory()->getMemory(romMemoryOffset);
	char * romImage = "Apple Graphics Tablet Interface Card ROM.bin";
	motherboard->getResources()->readResource(romMemory, 
		GRAPHICSTABLETINTERFACECARD_ROM_BYTENUM,
		romImage);
}

void GraphicsTabletInterfaceCard::writeIo(UINT16 address, UINT8 value) {
}

UINT8 GraphicsTabletInterfaceCard::readIo(UINT16 address) {
	return timingGenerator->readFloatingBus();
}

UINT8 GraphicsTabletInterfaceCard::readMemory(UINT16 address) {
	if ((address & 0xf00) == 0xf00)
		return timingGenerator->readFloatingBus();
	else
		return romMemory[address & 0x7ff];
}
